package com.chenggcode.simple.locator;

import org.springframework.beans.factory.config.ServiceLocatorFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Chenggcode
 * @date 2025/6/23 15:26
 */
@Configuration
public class Config {

    @Bean("parserServiceLocatorFactoryBean")
    public ServiceLocatorFactoryBean serviceLocatorFactoryBean() {
        ServiceLocatorFactoryBean factoryBean = new ServiceLocatorFactoryBean();
        // ServiceLocatorFactoryBean 会为ParserFactory生成代理类 -> ServiceLocatorInvocationHandler
        factoryBean.setServiceLocatorInterface(ParserFactory.class);
        return factoryBean;
    }
}
